<template>
  <div>
    <div>
      <el-table :data="returnShopInfoList">
        <el-table-column prop="returnNumber" label="退货编号">
          <template slot-scope="scope">
            <el-link type="primary" @click="showDetail(scope.row.id)">{{scope.row.returnNumber}}</el-link>
          </template>
        </el-table-column>
        <el-table-column prop="shopState" label="用户接收状态">
          <template slot-scope="scope">
            <div v-if="scope.row.shopState==0">未收到货</div>
            <div v-if="scope.row.shopState==1">已收到货</div>
          </template>
        </el-table-column>
        <el-table-column prop="returnCase.name" label="退货原因"></el-table-column>
        <el-table-column prop="money" label="退货金额"></el-table-column>
        <el-table-column prop="returnTime" label="退货时间"></el-table-column>
        <el-table-column prop="remark" label="退货备注"></el-table-column>
        <el-table-column label="退货单状态">
          <el-tag type="warning">用户退货，等待签收</el-tag>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button size="mini" type="danger" @click="audit(scope.row.id,7)">确认签收</el-button>
            <!--            <el-button size="mini" type="danger" @click="audit(scope.row.id,0)">拒绝签收</el-button>-->
          </template>
        </el-table-column>
      </el-table>
      <div>
        <!-- 分页 -->
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageno"
          :page-sizes="[5, 10, 15, 20]"
          :page-size="pagesize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </div>
      <div>
<!--        <show-details ref="showDetails"></show-details>-->
      </div>
    </div>
  </div>
</template>

<script>
    export default {
        name: "returnToSignFor",
        data(){
          return {
            returnShopInfoList: [],
            pageno: 1,
            pagesize: 5,
            total: 1
          }
        },
        methods:{
          getData() {
            let returnShopInfo={
              goodsState:6,//商户接收货物，等待总店人员取货，等待总店签收
              isDelete:0//未被删除
            };
            let params = new URLSearchParams();
            params.append("pageno", this.pageno);
            params.append("pagesize", this.pagesize);
            Object.keys(returnShopInfo).forEach(item => {
              params.append(item, returnShopInfo[item]);
            });
            this.$axios.get("queryAllReturn.action", {params: params})
              .then(res => {
                this.returnShopInfoList = res.data.records;
                this.total = res.data.total;
              })
              .catch(err => {
                this.$message.error(err)
              })
          },
          audit(id,goodsState){
            let refund={
              id:id,
              goodsState:goodsState
            };
            //调用异步，对退货单进行状态修改
            this.$axios.put("receiptForReturn.action",refund)
              .then(res=>{
                if(res.data.x){
                  this.$message.success(res.data.msg);
                }else {
                  this.$message.error(res.data.msg);
                }
                //重新查询一次数据
                this.getData();
              })
              .catch(err=>{
                this.$message.warning(err);
                alert(err);
              })
          },
          handleSizeChange(val) {
            //每页范围
            this.pagesize = val;
            this.getData();
          },
          handleCurrentChange(val) {
            //当前页
            this.pageno = val;
            this.getData();
          }
        },
        created() {
          this.getData();
        }
    }
</script>

<style scoped>

</style>
